var Fight,
  __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })();
!(function (t) {
  var e = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.waiting = !0),
        (e.closeHandler = new Handler(e, e.onCloseFn)),
        WebSocketService.addListener(
          { caller: e, code: 1027, method: e.onLoadQieCuoFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 718, method: e.onLoadQieCuoStateFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 1028, method: e.onLoadPkFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 1413, method: e.onLoadPkFn },
          !0
        ),
        e
      );
    }
    return (
      __extends(e, t),
      (e.open = function (t, i) {
        null == this.instance && (this.instance = new e());
        var n = this.instance;
        (n.btn_cancel.visible = !1),
          (n.label_time.visible = !1),
          (n.roleId = t),
          (n.label_content.text = "等待[" + i + "]接受邀请"),
          (n.label_time.text = "60"),
          (n.second = 60),
          n.popup(!0),
          WebSocketService.send({ c: 1027, d: { id: t } });
      }),
      (e.pk = function (t, i) {
        null == this.instance && (this.instance = new e());
        var n = Global.siteType;
        2 == n || 3 == n || 8 == n || 9 == n
          ? WebSocketService.send({ c: 1028, d: { id: t } })
          : i
          ? WebSocketService.send({ c: 1413, d: { id: t, gid: i } })
          : WebSocketService.send({ c: 1413, d: { id: t } });
      }),
      (e.prototype.onLoadQieCuoFn = function (t) {
        if (0 != t.code)
          return (
            (this.label_content.text = t.msg),
            (this.waiting = !1),
            void (this.btn_cancel.visible = !0)
          );
        (this.label_time.visible = !0),
          (this.waiting = !0),
          Laya.timer.loop(1100, this, this.refreshState);
      }),
      (e.prototype.refreshState = function () {
        this.second--,
          (this.label_time.text = this.second + ""),
          0 == this.second &&
            ((this.btn_cancel.visible = !0),
            (this.waiting = !1),
            (this.label_time.visible = !1),
            Laya.timer.clear(this, this.refreshState));
      }),
      (e.prototype.onLoadQieCuoStateFn = function (t) {
        if (0 != t.code)
          return (
            (this.label_content.text = t.msg),
            (this.btn_cancel.visible = !0),
            (this.label_time.visible = !1),
            (this.waiting = !1),
            void Laya.timer.clear(this, this.refreshState)
          );
        2 == t.data &&
          (Laya.timer.clear(this, this.refreshState), this.close(Dialog.OK));
      }),
      (e.prototype.onCloseFn = function (t) {}),
      (e.prototype.onLoadPkFn = function (t) {
        0 != t.code && ToastView.toastView(t.msg);
      }),
      (e.prototype.close = function (e) {
        ("side" == e && this.waiting) || t.prototype.close.call(this, e);
      }),
      e
    );
  })(ui.common.WaitFightUI);
  t.WaitFight = e;
})(Fight || (Fight = {}));
